using System.Diagnostics;
using System.IO;
using Microsoft.SmallBasic.Library;
using File = System.IO.File;

namespace SmallBasicFun
{
	/// <summary>
	/// 	Tools to help you display all types of files
	/// </summary>
	[SmallBasicType]
	public class Viewer
	{
		/// <summary>
		/// Display Rich Text Files (rtf). These are generally made in wordpad.
		/// </summary>
		/// <param name="contents">The contents of the rtf file. This will be saved to a temporary file and then opened</param>
		/// <example>
		/// words["name"] = "Charlie Brown"
		/// rtfContents = Parser.MergeRtfFile("c:\myTemplate.rft", words)
		/// Viewer.DisplayRtfFile(rtfContents)</example>
		/// <returns>The name of the temporary rtf file created.</returns>
		public static Primitive DisplayRtfFile(Primitive contents)
		{
			var file = Path.GetTempFileName() + ".rtf";
			File.WriteAllText(file, contents);
			Process.Start(file);
			return file;
		}

	}
}